package org.wings27.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.wings27.interfaces.IProblemPreprocessService;
import org.wings27.interfaces.IProblemService;

import java.util.ArrayList;

/**
 * Project Name: answerIt
 * Date Created: 2013/11/19 15:19
 *
 * @author wings
 */
public class ProblemService implements IProblemService {
    private boolean isAutoFormat;
    private String beforeBlank;
    private String afterBlank;
    private ArrayList<String> choices;
    private String problem;
    @Autowired
    private IProblemPreprocessService problemPreProcess;

    @Override
    public void format() {
        getProblemPreProcess().process(this);
    }

    @Override
    public String getBeforeBlank() {
        return beforeBlank;
    }

    @Override
    public void setBeforeBlank(String beforeBlank) {
        this.beforeBlank = beforeBlank;
    }

    @Override
    public String getAfterBlank() {
        return afterBlank;
    }

    @Override
    public void setAfterBlank(String afterBlank) {
        this.afterBlank = afterBlank;
    }

    @Override
    public String getProblem() {
        return this.problem;
    }

    @Override
    public void setProblem(String problem) {
        this.problem = problem;
        if (isAutoFormat()) {
            format();
        }
    }

    @Override
    public ArrayList<String> getChoices() {
        return choices;
    }

    @Override
    public void setChoices(ArrayList<String> choices) {
        this.choices = choices;
    }

    @Override
    public String toString() {
        return this.getBeforeBlank() + IProblemPreprocessService.DEFAULT_BLANK_SYMBOL + this.getAfterBlank();
    }

    public IProblemPreprocessService getProblemPreProcess() {
        return problemPreProcess;
    }

    public void setProblemPreProcess(IProblemPreprocessService problemPreProcess) {
        this.problemPreProcess = problemPreProcess;
    }

    public boolean isAutoFormat() {
        return isAutoFormat;
    }

    public void setAutoFormat(boolean autoFormat) {
        this.isAutoFormat = autoFormat;
    }
}
